package com.joolun.web.controller.mall;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.joolun.common.annotation.Log;
import com.joolun.common.core.domain.AjaxResult;
import com.joolun.common.enums.BusinessType;
import com.joolun.common.utils.poi.ExcelUtil;
import com.joolun.mall.entity.ChainPlanReserveOrder;
import com.joolun.mall.entity.DwsVipOrderStat;
import com.joolun.mall.service.DwsVipOrderStatService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * VIP订单统计
 *
 * @author www.joolun.com
 * @date 2025-05-20
 */
@RestController
@RequestMapping("/vipOrderStat")
public class DwsVipOrderStatController {

    @Autowired
    private DwsVipOrderStatService vipStatService;

    /**
     * 获取店铺列表
     * @return
     */
    @GetMapping("/shopList")
    public AjaxResult shopList()
    {
        return AjaxResult.success(vipStatService.shopList());
    }

    /**
     * VIP订单统计-分页
     * @param page
     * @param query
     * @return
     */
    @Log(title = "VIP订单统计-分页", businessType = BusinessType.QUERY)
    @GetMapping("/page")
    public AjaxResult<Page<DwsVipOrderStat>> page(Page<DwsVipOrderStat> page, DwsVipOrderStat query)
    {
        Page<DwsVipOrderStat> page1 = vipStatService.page1(page, query);
        return AjaxResult.success(page1);
    }

    /**
     * VIP订单统计-汇总统计
     * @param page
     * @param query
     * @return
     */
    @GetMapping("/total")
    public AjaxResult<DwsVipOrderStat> total(Page<DwsVipOrderStat> page, DwsVipOrderStat query)
    {

        return AjaxResult.success(vipStatService.total(query));
    }

    /**
     * VIP订单统计-导出
     */
    //    @PreAuthorize("@ss.hasPermi('mall:reserveorder:export')")
    @Log(title = "VIP订单情况-导出", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Page<DwsVipOrderStat> page, DwsVipOrderStat query)
    {
        page.setSearchCount( false);
        page.setSize(-1);
        Page<DwsVipOrderStat> page1 = vipStatService.page1(page, query);
        ExcelUtil<DwsVipOrderStat> util = new ExcelUtil<>(DwsVipOrderStat.class);
        return util.exportExcel(page1.getRecords(), "VIP订单情况");
    }


}
